﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<style>
	.checkbox{
	float:right;
	width:50px;
	margin-left:-30px
	}
</style>
    <base href="<%=basePath%>">
    <%@ include file="topa.jsp" %>
    <!-- jsp文件头和头部 -->
    <script src='static/js/jquery-1.9.1.min.js'></script>
    <script type="text/javascript" src="static/js/myjs/head.js${getTime}"></script>
    <script type="text/javascript" src="static/js/layer.js"></script>
    <link rel="stylesheet" href="static/css/layui.css" media="all">
    <script type="text/javascript">
        $(function () {
            $("#createContract").click(function () {

                //提交表单
                layer.confirm('确定将任务分配吗? ', {
                    btn: ['确定', '取消']
                    //按钮
                }, function () {
                	var a = $("[name='userid']:checked");
                    var total = '${total}';
                    var size = $("#fenpaiPagesize").val();
                    var len = a.length;
                    var feitotal= total;
                        if((parseInt(total)>parseInt(size))){
                            feitotal=size;
                    }else {
                        feitotal = total;
                    }
                    if(len>feitotal){
                        layer.msg('任务总数不能小于人数', {
                            icon: 1,
                            time: 2000,
                         });
                        return ;
                       }
                    if (len > 0) {
                        layer.confirm("任务总数"+feitotal+",分配人数"+len+",每人分"+parseInt(feitotal/len)+"个案件，还有"+feitotal%len+"个案件不能分", {
                            btn: ['确定','取消'], //按钮
							shade:[0.3,'pink']
						}, function(){
                            var data = $("#pageForm").submit();
                            closeAply();
                            layer.msg('分配成功', {icon: 1});
                        }, function(){
                            layer.msg('已取消', {
                                time: 2000, //20s后自动关闭
                            });
                        });
                    } else {
                        layer.msg('请勾选催收员', {
                            icon: 2,
                            time: 2000,
                        });
                    }

                }, function () {
                    layer.msg('考虑清楚后再来找我哦', {
                        icon: 2,
                        time: 2000, //20s后自动关闭
                    });
                });

            })

        })
        function closeAply() {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index);
        }
        function quanxuanAll(){
          console.log("全选")
            if($("#quanxuan").get(0).checked){
                var objs = document.getElementsByName('userid')
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=true;
                }
            }else{
                var objs = document.getElementsByName('userid')
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=false;;
                }
            }
        }
        function quanxuanAlls1(){
            console.log("s1全选")
            if($("#quanxuanS1").get(0).checked){
                var objs =  $("[team1]")
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=true;
                }
            }else{
                var objs =  $("[team1]")
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=false;
                }
            }
        }
        function quanxuanAlls2(){
            console.log("s2全选")
            if($("#quanxuanS2").get(0).checked){
                var objs =  $("[team2]")
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=true;
                }
            }else{
                var objs =  $("[team2]")
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=false;
                }
            }
        }
        function quanxuansAlls21(){
            console.log("s2+全选")
            if($("#quanxuanS21").get(0).checked){
                var objs =  $("[team3]")
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=true;
                }
            }else{
                var objs =  $("[team3]")
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked=false;
                }
            }
        }
    </script>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">

                <form action="<%=basePath%>taskdetails/pilianguser2" method="post"
                      name="pageForm" id="pageForm">
                    <input type="hidden" id="status" name="status" value="${status}">
                    <input type="hidden" id="fpId" name="fpId" value="${fpId }">
                    <input type="hidden" id="flag" name="flag" value="${flag }">
                    <input type="hidden" id="total" name="totalTask" value="${total}">
                    <input type="hidden" id="currentUserId" name="currentUserId" value="${currentUserId }">
                    <fieldset class="layui-elem-field">
                        <legend>任务数量：${total }</legend>
                        <div class="pull-right" style="text-align: center;margin-right: 60px;margin-top:-5px">
                            选择总数:
                            <select id="fenpaiPagesize" name="fenpaiPagesize" style="width: 100px;height: 25px;">
                                <option value="50">50</option>
                                <option value="100">100</option>
                                <option value="200">200</option>
                                <option value="500">500</option>
                                <option value="1000">1000</option>
                            </select>
                        </div>
                        <div class="layui-field-box">
                            催收人员：<%--<input type="checkbox" style="border: 1px solid #000;opacity: 1;margin-left: 20px" onclick="quanxuanAll()" id="quanxuan"/>&nbsp;&nbsp;全选--%>
                                <!-- 开始循环 -->
                                <hr>
                                <h3 style="background-color: gray;width: 50px;height: 30px;display: inline-block">&emsp;S1 </h3>
                          <%--  <input type="checkbox" style="border: 1px solid #000;opacity: 1;margin-left: 20px" onclick="quanxuanAlls1()" id="quanxuanS1"/>--%>
                           <div style="border-left:0px;padding: 10px;display: inline-block"  width="70px">
                            <input type="checkbox" style="border: 1px solid #000;opacity: 1;"  onclick="quanxuanAlls1()" id="quanxuanS1"/>
                            <label for="quanxuanS1" style="float:right;width:65px;">&nbsp;&nbsp;S1全选</label>
                               </div>
                                <c:choose>
                                    <c:when test="${not empty userpage1}">
                                   		<div class="checkbox" style="border:0px solid #ccc; width: 750PX; margin-left: 0px;">
											 <table><tr height="40px">
											 <c:forEach items="${userpage1}" var="var"  varStatus="status">
												<td style="border-left:0px;padding: 10px;"  width="70px">
												<input type="checkbox" style="border: 1px solid #000;opacity: 1;" id="${var.userid}"; name="userid" team1="s1" value="${var.userid}"/>
                                                    <label for="${var.userid}" style="float:right;width:70px;margin-left:-30px"> ${var.name}</label>
                                                </td>
												  <c:if test="${status.count%5==0}">
													 </tr>
													  <tr height="40px">
													 </c:if>
											 </c:forEach>
													  </tr>
											 </table>
										 </div>
                                    </c:when>
                                    <c:otherwise>
                                        <tr class="main_info">
                                            <td colspan="100" class="center">没有相关数据</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                             <hr>
                            <h3 style="background-color: gray;width: 50px;height: 30px;display: inline-block">&emsp;S2</h3>
                       <%-- <input type="checkbox" style="border: 1px solid #000;opacity: 1;margin-left: 20px" onclick="quanxuanAlls2()" id="quanxuanS2"/>&nbsp;&nbsp;S2全选--%>
                            <div style="border-left:0px;padding: 10px;display: inline-block"  width="70px">
                                <input type="checkbox" style="border: 1px solid #000;opacity: 1;" onclick="quanxuanAlls2()" id="quanxuanS2"/>
                                <label for="quanxuanS2" style="float:right;width:65px;">&nbsp;&nbsp;S2全选</label>
                            </div>
                                <c:choose>
                                    <c:when test="${not empty userpage2}">
                                   		<div class="checkbox" style="border:0px solid #ccc; width: 750PX; margin-left: 0px;">
											 <table><tr height="40px">
											 <c:forEach items="${userpage2 }" var="var"  varStatus="status">
												<td style="border-left:0px;padding: 10px;" width="70px">
												<input type="checkbox" style="border: 1px solid #000;opacity: 1;" id="${var.userid}"; name="userid" team2="s2" value="${var.userid}"/>
                                                   <label for="${var.userid}" style="float:right;width:70px;margin-left:-30px"> ${var.name}</label>
                                                </td>
												  <c:if test="${status.count%5==0}">
													 </tr>
													  <tr height="40px">
													 </c:if>
											 </c:forEach>
													  </tr>
											 </table>
										 </div>
                                    </c:when>
                                    <c:otherwise>
                                        <tr class="main_info">
                                            <td colspan="100" class="center">没有相关数据</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                                <hr>
                         <h3 style="background-color: gray;width: 50px;height: 30px;display: inline-block">&emsp;S2+</h3>
                     <%-- <input type="checkbox" style="border: 1px solid #000;opacity: 1;margin-left: 20px" onclick="quanxuansAlls21()" id="quanxuanS21"/>&nbsp;&nbsp;S2+全选--%>
                            <div style="border-left:0px;padding: 10px;display: inline-block"  width="70px">
                                <input type="checkbox" style="border: 1px solid #000;opacity: 1;" onclick="quanxuansAlls21()" id="quanxuanS21"/>
                                <label for="quanxuanS21" style="float:right;width:65px;">&nbsp;&nbsp;S2+全选</label>
                            </div>
                                <c:choose>
                                    <c:when test="${not empty userpage3}">
                                   		<div class="checkbox" style="border:0px solid #ccc; width: 750PX; margin-left: 0px;">
											 <table><tr height="40px">
											 <c:forEach items="${userpage3 }" var="var"  varStatus="status">
												<td style="border-left:0px;padding: 10px;" width="70px">
												<input type="checkbox" style="border: 1px solid #000;opacity: 1;" id="${var.userid}"; name="userid" team3="s21" value="${var.userid}"/>
                                                     <label for="${var.userid}" style="float:right;width:70px;margin-left:-30px">${var.name}</label>
												</td>
												  <c:if test="${status.count%5==0}">
													 </tr>
													  <tr height="40px">
													 </c:if>
											 </c:forEach>
													  </tr>
											 </table>
										 </div>
                                          <%--  <c:forEach items="${userpage }" var="var" varStatus="vs">
                                               <tr>
                                                   <td><input type="radio" id="userid" name=userid class="userById"
                                                              value="${var.userid }">${var.name}</td>
                                               </tr>
                                           </c:forEach> --%>
                                    </c:when>
                                    <c:otherwise>
                                        <tr class="main_info">
                                            <td colspan="100" class="center">没有相关数据</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                        </div>
                        <%-- <div class="page-header position-relative">
                            <table style="width: 100%;">
                                <tr>
                                    <td style="vertical-align: top;">
                                        <div class="pagination"
                                            style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div> --%>
                        <button id="createContract" type="button" class="btn btn-primary">分派</button>
                        <button type="button" class="btn btn-default"
                                data-dismiss="modal" onclick="closeAply()">关闭
                        </button>

                    </fieldset>
                </form>


            </div>
        </div>
    </div>
</div>
<!-- 引入 -->
<script type="text/javascript">
    window.jQuery
    || document
        .write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");
</script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/ace-elements.min.js"></script>
<script src="static/js/ace.min.js"></script>
<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
<script type="text/javascript"
        src="static/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="static/js/bootbox.min.js"></script>
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</body>
</html>

